package com.huibo.shopping.product.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.huibo.shopping.common.interfaces.RedisInterface;
import com.huibo.shopping.domain.Product;
import com.huibo.shopping.util.AjaxResult;

@RestController
@RequestMapping("/product")
public class ProductController {
	
	@Autowired
	private RedisInterface redisInterface;
	
	@GetMapping("/select")
	public AjaxResult selectProduct() {
		try {
			Product p = new Product();
			p.setId(1);
			p.setName("shy");
			p.setAge(23);
			return AjaxResult.getInstance().setMsg("查询成功-对吧").setData(p);
		} catch (Exception e) {
			e.printStackTrace();
			return AjaxResult.getInstance().setMsg("查询失败").setCode(500);
		}
	}
	
	@GetMapping("/getValue")
	public String getValue(String key) {
		System.err.println("123");
		return redisInterface.get(key);
	}
}
